package com.wsoft.system.controller;

import com.wsoft.response.ResponsePage;
import com.wsoft.response.ResponseResult;
import com.wsoft.system.query.member.MemberOrgPostQuery;
import com.wsoft.system.query.post.MemberPostQuery;
import com.wsoft.system.service.ISysMemberOrgPostRelationService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 人员组织用户关联表 前端控制器
 * @author juiet
 * @since 2024年09月27日 13:07:12
 */
@RestController
@Tag(name = "人员组织岗位管理")
@RequestMapping("/sys/memberOrgPostRelation")
public class SysMemberOrgPostRelationController {

    @Resource
    private ISysMemberOrgPostRelationService memberOrgPostRelationService;
    @Operation(summary = "新增人员组织岗位关系",description = "新增人员组织岗位关系")
    @PostMapping("/insert")
    public ResponseResult insert(@RequestBody @Valid MemberOrgPostQuery query) {
        memberOrgPostRelationService.insertRelations(query);
        return ResponseResult.success("[sys.msg.success]");
    }
    @Operation(summary = "修改人员组织岗位关系",description = "修改人员组织岗位关系")
    @PostMapping("/update")
    public ResponseResult update(@RequestBody @Valid MemberOrgPostQuery query) {
        memberOrgPostRelationService.updateRelations(query);
        return ResponseResult.success("[sys.msg.success]");
    }

    @Operation(summary = "获取人员组织岗位关系列表",description = "获取人员组织岗位关系列表")
    @GetMapping("/get")
    public ResponseResult get(@RequestParam("memberId") Long memberId) {
        return ResponseResult.success(memberOrgPostRelationService.getPostListByMember(memberId));
    }

    @Operation(summary = "根据岗位获取人员列表",description = "根据岗位获取人员列表")
    @PostMapping("/pageMemberListByPost")
    public ResponseResult pageMemberListByPost(@RequestBody @Valid MemberPostQuery query) {
        return ResponseResult.success(ResponsePage.restPage(memberOrgPostRelationService.getMemberListByPost(query)));
    }
}
